'use strict';
module.exports = app => {
    const { STRING, INTEGER, TINYINT } = app.Sequelize;
    const Model = app.model.define(
        'room',
        {
            id: {type: INTEGER, primaryKey: true, autoIncrement: true},
            /**
             * `company` int DEFAULT NULL COMMENT '公司',
             *   `buildingName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '舍名',
             *   `buildingNo` varchar(20) DEFAULT NULL COMMENT '舍号',
             *   `roomInfo` varchar(50) DEFAULT NULL COMMENT '栏位信息',
             *   `version` int DEFAULT '1',
             *   `is_deleted` tinyint(1) DEFAULT '0',
             */
            company: INTEGER,
            buildingname: STRING(50),
            buildingno: STRING(20),
            roominfo: STRING(50),
            version: INTEGER,
            is_deleted: TINYINT(1),
        },
        {
            tableName: 'farmview',
            timestamps: true, // 启用时间戳(createdAt, updatedAt)
            updatedAt: false, // 不想要 updatedAt
            createdAt: false, // 想要  createdAt 但是希望名称叫做 created_at
        }
    );
    Model.associate = function() {
        app.model.Room.belongsTo(app.model.CompanyModel, { foreignKey: 'company', targetKey: 'id' });
    }
    return Model
};
